	//스코어상세
	function clsScoreView(){
		this.listData = null;
		this._HTMLDom = null;
		this._init();
	}	
	
	clsScoreView.prototype = {
		_init: function(){
			var $layer = $("section#my_score_view>section");
			this._HTMLDom = {
				"$layer": $layer
			};
		}	
		, setData: function(thisData){
			this.listData = thisData;
			this.display();
		}
		, display: function(){			
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			//라운드일자, 코스, 홀, 이미지, 내용, 스코어수, 스코어카드[]			
			$layer.find("dd:eq(0) ul li:eq(0) div p").html(this.listData["날짜"] + "("+this.listData["요일"]+")");
			$layer.find("dd:eq(0) ul li:eq(1) div p").html(this.listData["골프장코스명"]);
			$layer.find("dd:eq(0) ul li:eq(2) div p").html(this.listData["홀"] + "&nbsp;H");
			
			$layer.find("dd:eq(1) span img").attr("src", _util.filePath2Url(this.listData["파일정보"]["파일명"])).error(function(){
				$(this).attr("src", "../images/default_200_250.gif");
			});
			$layer.find("dd:eq(1)").contents().filter(function(){
				return (this.nodeType==3&&this.data.trim());
			}).after(this.listData["내용"]).remove();
			
			this.mergeSocreCard();
			
		}
		, mergeSocreCard: function(){		
			var $layer = this._HTMLDom["$layer"];
				
			var sum = {
				"4이상": 0
				, "트리플보기": 0
				, "더블보기": 0
				, "보기": 0
				, "파": 0
				, "버디": 0
				, "이글": 0
				, "홀인원": 0
			}
			
			var aMap = [
				"4이상"
				, "트리플보기"
				, "더블보기"
				, "보기"
				, "파"
				, "버디"
				, "이글"
				, "홀인원"
			];
			
			var tScore = 0;
			for(var i=0;i<this.listData["파"].length;i++){
				var p = parseInt(this.listData["파"][i]);
				var t = parseInt(this.listData["타"][i]);
				tScore += this.listData["스코어"][i];
				
				p = p || 0;
				t = t || 0;
				
				if(p < 3 || p > 5) continue;
				
				if(t >= 0){
					switch(t){
						case 0:
							sum["파"]++;
							break;
						case 1:
							sum["보기"]++;
							break;
						case 2:
							sum["더블보기"]++;
							break;
						case 3:
							sum["트리플보기"]++;
							break;
						default:
							sum["4이상"]++;
							break;
					}
				}else if(t == -1){
					sum["버디"]++;
				}else if((p + t) == 1){
					sum["홀인원"]++;
				}else if((p == 4 || p == 5) && t == -2){
					sum["이글"]++;
				}
			}
		
			$layer.find("dt a span:eq(1) span.sc_count").html(tScore);
			$layer.find("dd:eq(2) table:eq(0) tbody tr td:eq(0)").html(sum["4이상"]);
			$layer.find("dd:eq(2) table:eq(0) tbody tr td:eq(1)").html(sum["트리플보기"]);
			$layer.find("dd:eq(2) table:eq(0) tbody tr td:eq(2)").html(sum["더블보기"]);
			$layer.find("dd:eq(2) table:eq(0) tbody tr td:eq(3)").html(sum["보기"]);
			
			$layer.find("dd:eq(2) table:eq(1) tbody tr td:eq(0)").html(sum["파"]);
			$layer.find("dd:eq(2) table:eq(1) tbody tr td:eq(1)").html(sum["버디"]);
			$layer.find("dd:eq(2) table:eq(1) tbody tr td:eq(2)").html(sum["이글"]);
			$layer.find("dd:eq(2) table:eq(1) tbody tr td:eq(3)").html(sum["홀인원"]);
			
		}
		, spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
			$.mobile.hidePageLoadingMsg();				
		}
		, $getBtnImg: function(){
			return $("dd:eq(1)>span");
		}
		, $getBtnScore: function(){			
			return this._HTMLDom["$layer"].find("dt a");
		}
		, $getBtnUpdate: function(){
			return this._HTMLDom["$layer"].find("div.btn_area02 div:eq(0)");	
		}
		, $getBtnDelete: function(){
			return this._HTMLDom["$layer"].find("div.btn_area02 div:eq(1)");
		}
	}
	
	//데이터연동		
	function clsComm_MyScoreView(){
		this.scoreView = null;		
		this.scoreViewRequest = null;
		
		this._init();
	}	
	clsComm_MyScoreView.prototype = {
		_init: function(){
			this.scoreViewRequest = {
				"아이디": "golfin"	
				, "페이지": null
				, "스코어키": null
			}
		}
//------------------------ 스코어상세조회------------------------//	
		, getScoreView: function(){
			var thisClass = this;
						
			var szReservSeq = this.scoreViewRequest["예약코드"];			
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", "golfin3");
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyScoreCard");
        		
        	objJson.putParameter("reservSeq", szReservSeq);
        	
        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					var hole = 0;
					if(!items.length) items = new Array(items);
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						var golfCourseName = "";
						if(szReservSeq.substrEx(0, 1) == "D"){
							golfCourseName = _util.nvl(obj["golfclubId"]);
						}else{
							golfCourseName = _util.nvl(obj["golfclubName"]) + "/" + _util.nvl(obj["courseInfoName"]);
						}
						
						if(i==0){
							thisClass.scoreView = {
								"날짜": _util.nvl(obj["reservDate"])
								, "요일": _util.nvl(obj["week"])
								, "골프장코스명": golfCourseName
								, "홀": 0
								, "파일정보": {
									"파일코드": _util.nvl(obj["fileSeq"])
									, "파일명": _util.nvl(obj["path"]) + _util.nvl(obj["saveFileName"])
									, "원본파일명": _util.nvl(obj["orgnFileName"])
								}
								, "내용": _util.nvl(obj["contents"])
								, "파": []
								, "스코어": []
								, "타": []								
							}
						}
						thisClass.scoreView["홀"] += _util.nvl(obj["holeCnt" + (i+1)], 0);
						
						for(j=0;j<_util.nvl(obj["holeCnt" + (i+1)], 0);j++){
							var s = _util.nvl(obj["score" + (j+1) + "h"], 0);
							var p = _util.nvl(obj["par" + (j+1) + "h"], 0);
							
							thisClass.scoreView["파"].push(p);
							thisClass.scoreView["스코어"].push(s);
							thisClass.scoreView["타"].push(s-p);
						}
					}
				}
				
				$(thisClass).trigger("evtFinishScoreView");
			}, function($err) {
				alert($err);
			});			
		}
		, getScoreViewData: function(){
			return this.scoreView;	
		}
		, setScoreViewRequest: function(key,val){
			this.scoreViewRequest[key]=val;
		}
		, getScoreViewRequest: function(key){
			return this.scoreViewRequest[key];
		}
//------------------------ 스코어상세조회------------------------//			
//------------------------ 스코어삭제------------------------//	
		, DeleteScore: function(arg){
			var thisClass = this;		
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();
			
			objJson.putClient("userid", "golfin3");
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "deleteMyScoreCard");
        	objJson.putParameter("reservSeq", arg["예약코드"]);

        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var resData = {
					"응답코드": (ret["msp"]["contents"]["serviceResult"]=="00000"?true:false)
					, "메세지": (ret["msp"]["contents"]["serviceResult"]=="00000"?"스코어가 삭제되었습니다.":"오류발생")
				}
				 
				$(thisClass).trigger("evtFinishScoreDelete", resData);
				
			}, function($err) {
				alert($err);
			});			
		}
//------------------------ 스코어삭제------------------------//			
	}
	
	//컨트롤파일
	function MyScoreView(){
		this.objParam = null;
		this.objComm = null;	
		this.objScoreView = null;
		
		this.reserv_seq = null;		
	};
	
	MyScoreView.prototype = {
	    onPageShow : function() {
	    	$("a").attr("href", "").attr("data-rel", "");  
	    	$("section#my_score_view header div.top_title_G div a").attr("data-rel","").attr("data-direction", "");   
	    	this._init();	    		    	
	    }
	    , _init: function(){	    		    	
	    	this.objComm = new clsComm_MyScoreView();
	      	this.objScoreView = new clsScoreView();
	      		     	
	      this.getParam();
	    	
	    	this._role();
	       
	      	this._bind();	
	      	this._eventFinish();
	    }
	    , _start: function(){
	      	//스코어목록 조회
	      	this.objScoreView.spinStart();
	      	
	      	this.objComm.setScoreViewRequest("예약코드",this.reserv_seq);
	      	this.objComm.setScoreViewRequest("페이지",1);
	      	this.objComm.getScoreView();
	    }
		, _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//스코어상세정보조회 완료 이벤트
		 	$(this.objComm).bind("evtFinishScoreView", function(event){
		 		var thisData = thisClass.objComm.getScoreViewData();
		 		thisClass.objScoreView.setData(thisData);
		 		thisClass.objScoreView.spinEnd();
		 	});
		}
		, _bind: function(){
		 	var thisClass = this;
		 	
		 	//스코어삭제 완료이벤트
		 	$(this.objComm).bind("evtFinishScoreDelete", function(event, resData){
		 		alert(resData["메세지"]);
		 		if(resData["응답코드"]){
		 			$.mobile.changePage( "my_score.html","slide",true);	
		 		}
		 	});
		 	
		 	//이미지크게보기
		 	this.objScoreView.$getBtnImg().on("click","a",function(event){
		 		alert("이미지크게보기");
		 	});
		 	
		 	//스코어카드보기
		 	this.objScoreView.$getBtnScore().click(function(event){
		 		//<--초기화
		 		if(!_gf.MYPAGE_DATA) {
			 		_gf.MYPAGE_DATA  = {
			 			"스코어코드": thisClass.reserv_seq	
			 		}
			 	}else {
			 		_gf.MYPAGE_DATA["예약코드"] = thisClass.reserv_seq;
			 	}
			 	//초기화-->		 		
		 		$.mobile.changePage("my_card_view.html","slide",true);	
		 	});
		 			 	
		 	//수정
		 	this.objScoreView.$getBtnUpdate().click(function(event){
		 		$.mobile.changePage( "my_score_modify.html","slide",true);	
		 	});
		 		
		 	//삭제
		 	this.objScoreView.$getBtnDelete().click(function(event){
		 		thisClass.objScoreView.spinStart();
		 		var sumbitData = {
		 			"예약코드": thisClass.reserv_seq
		 		}
		 		thisClass.objComm.DeleteScore(sumbitData);
		 	});
		 	
		 	//메뉴
		 	$("section#my_score_view nav ul li a:eq(0)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage( "../inc/navi.html","slide",true);	
		 	});
		 	
		 	//알림
		 	$("section#my_score_view nav ul li:eq(1)").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("../inc/info_booking.html","slide",true);	
		 	});
		 	
		 	//뒤로가기		 
		 	$("section#my_score_view header div.top_title_G div a").click(function(event){
		 		event.preventDefault();
		 		$.mobile.changePage("my_score.html","slide",true);	
		 	});
		 } 
		 , getParam: function(){
	    	if(_gf.MYPAGE_DATA){	    		
	    		this.reserv_seq = _util.nvl(_gf.MYPAGE_DATA["예약코드"]);	
	    	}
	    }
	    , _role: function(){
	    		if(!_util.getLogin("로그인")){
	    			alert("로그인 후 이용하실 수 있습니다.");		    			
	    			this.goNavi();		
	    			return;    	
	    		}

	    		if(!this.reserv_seq){
    				//alert("비정상적인 접근입니다.");
    				//$.mobile.changePage( "my_score.html","slide",true);	
	    		}
	    		
	    		this._start();
	    }
		, goNavi: function(){
    		$.mobile.changePage("../inc/navi.html","slide",true);
		}
	}	